import request from '@/utils/request.ts'
import { PageData } from '@/types/resp.ts'
import { Tag, TagPageParam, TagSaveParam, TagListParam, TagRemoveParam } from '@/types'

export const page = (param: TagPageParam): Promise<PageData<Tag>> => {
  return request({
    url: '/tag/page',
    method: 'post',
    data: param,
  })
}

export const save = (param: TagSaveParam): Promise<Tag> => {
  return request({
    url: '/tag/save',
    method: 'post',
    data: param,
  })
}

export const update = (param: { id: string; color?: string; icon?: string }): Promise<Tag> => {
  return request({
    url: '/tag/update',
    method: 'post',
    data: param,
  })
}

export const list = (param: TagListParam): Promise<Tag[]> => {
  return request({
    url: '/tag/list',
    method: 'post',
    data: param,
  })
}

export const remove = (param: TagRemoveParam): Promise<unknown> => {
  return request({
    url: '/tag/remove',
    method: 'post',
    data: param,
  })
}
